package com.scuec.tourismwebsite.controller;

import com.github.pagehelper.PageInfo;
import com.scuec.tourismwebsite.entity.WeatherRealTime;
import com.scuec.tourismwebsite.service.WeatherRealTimeService;
import com.scuec.tourismwebsite.vo.ViewWeatherRealTimeWithCity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/weather_real_time")
@CrossOrigin

public class WeatherRealTimeController {

    @Autowired
    private WeatherRealTimeService weatherRealTimeService;

    @GetMapping("/page")
    public PageInfo<ViewWeatherRealTimeWithCity> getWeatherRealTimeWithCity(Integer pageNum, Integer pageSize) {
        PageInfo<ViewWeatherRealTimeWithCity> pageInfo = weatherRealTimeService.findWeatherRealTimePages(pageNum,pageSize);
        return pageInfo;
    }

    @GetMapping("/query")
    public List<ViewWeatherRealTimeWithCity> getWeatherRealTime(){
        return weatherRealTimeService.getWeatherRealTime();
    }

    @PostMapping("/insert")
    public Integer insertWeatherRealTime(@RequestBody WeatherRealTime weatherRealTime){
        return weatherRealTimeService.insertWeatherRealTime(weatherRealTime);
    }

    @PutMapping("/update")
    public Integer updateWeatherRealTime(@RequestBody WeatherRealTime weatherRealTime){
        return weatherRealTimeService.updateWeatherRealTime(weatherRealTime);
    }
    @DeleteMapping("/delete")
    public Integer deleteWeatherRealTime(Integer weather_id){
        return weatherRealTimeService.deleteWeatherRealTime(weather_id);
    }

}
//1